//-----------------------------------------------------------------------------
//  Copyright (C) 2005-2008 Thomas S. Ullrich 
//
//  This file is part of the Solitaire Mahjong project.
//
//  This file may be used under the terms of the GNU General Public License.
//  This project is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License.
//  
//  Author: Thomas S. Ullrich
//  Last update: June 1, 2007
//-----------------------------------------------------------------------------
#ifndef smTileLayout_h
#define smTileLayout_h
 
#include <vector>
#include "smDefinitions.h"
using namespace std;

class smTileItem;
 
class smTileLayout
{
public:
    smTileLayout();
    ~smTileLayout();
 
    bool  makeLayout(smTileLayoutId);
    QSize layoutTiles(vector<smTileItem*>&, int, int);
 
    int rows() const;
    int columns() const;
    int layers() const;
    bool isAtBorder(const smTileItem*) const;
    void removeTile(const smTileItem*);
    void undoRemoveTile(const smTileItem*);
    void asciiPrintLayout();
 
protected:
    int depth(int, int, int) const;
 
private:
    enum { isEmpty=0, isTile, isXOffsetTile, isYOffsetTile, isXYOffsetTile };
    int  mRows;
    int  mColumns;
    int  mNumberOfLayers;
    bool mValidLayoutLoaded;
    vector<vector<vector<int> > > mLayout;  // mLayout[layer][col][row]
    vector<vector<vector<int> > > mTopoLayout;
};
 
inline int smTileLayout::rows() const {return mRows;}
inline int smTileLayout::columns() const {return mColumns;}
inline int smTileLayout::layers() const {return mNumberOfLayers;}
#endif
